package com.bw.service;

import com.bw.dao.UserDao;
import com.bw.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/***************************
 FileAction: 用户服务层

 CreateTime:2022-07-25 14:35
 Author:Aaking-aline
 ****************************/
@Service
public class UserService{

	@Autowired
	private UserDao userDao;

	public boolean login(User user) {

		List<User> list = null;


		list = userDao.selectUser(user);


		if(list == null){
			return false;
		}

		if(list.isEmpty()){
			return false;
		}

		return true;
	}

	public boolean register(User user) {

		List<User> list = null;

		list = userDao.selectUser(user);

		if(list == null){
			return false;
		}

		if(list.isEmpty()){
			userDao.insertUser(user);
			return true;
		}

		return false;
	}
}
